package com.swiftair.view
{
	import com.swiftair.ApplicationFacade;
	import com.swiftair.view.components.StatusesList;
	
	import flash.events.Event;
	
	import mx.collections.ArrayCollection;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

    public class StatusesListMediator extends Mediator implements IMediator
    {
        // Cannonical name of the Mediator
        public static const NAME:String = "StatusesListMediator";
		// List types
		public static const HOME:String = "homeType";
		public static const MENTIONS:String = "mentionsType";
		// Statuses list type
		private var _type:String;

        public function StatusesListMediator(viewComponent:StatusesList, type:String=null) {
            super(NAME, viewComponent);
			_type = type;
			setupHandlers();
		}

        override public function listNotificationInterests():Array {
            return [ApplicationFacade.MODEL_STATUSES_LOADED];
        }

        override public function handleNotification(note:INotification):void {
			switch (note.getName()) {
				case ApplicationFacade.MODEL_STATUSES_LOADED:
					if(note.getType() == _type)
						list.collection = note.getBody() as ArrayCollection;
					break;
			}
        }

        protected function get list():StatusesList {
            return viewComponent as StatusesList;
        }
		
		private function setupHandlers():void {

		}
    }
}